package com.stu.algorithm;

public class Main {
  public static void main(String[] args) {
    test1(5);
  }

  public static void test1(int xy) {
    int[][] ints = new int[xy][xy];
    for(int i=0; i<ints.length; i++) {
      for(int j=0; j<=i; j++) {
        if(j==0 || j==i) {
          ints[i][j] = 1;
        } else {
          // ints[2][1] = ints[1][0] + ints[1][1]
          ints[i][j] = ints[i-1][j-1] + ints[i-1][j];
        }
      }
    }

    for(int i=0; i<ints.length; i++) {
      for(int j=0; j<ints.length-i-1; j++) {
        System.out.print(" ");
      }
      for(int j=0; j<=i; j++) {
        System.out.print(ints[i][j]+" ");
      }
      System.out.println();
    }
  }
  
}
